package top.oneit.jdownload.utils;

import cn.hutool.core.lang.Assert;
import javafx.fxml.FXMLLoader;

import java.net.URL;

public class XmlUtils<T> {

    public static <T> T loadXML(String path) {
        URL resource = XmlUtils.class.getResource(path);
        FXMLLoader fxmlLoader = new FXMLLoader(resource);
        try {
            return fxmlLoader.load();
        } catch (Exception e) {
            e.printStackTrace();
            Assert.isNull(e, "加载xml失败！");
        }
        return null;
    }

    public static FXMLLoader getFXMLLoader(String path){
        URL resource = XmlUtils.class.getResource(path);
       return new FXMLLoader(resource);
    }

}
